package com.ericsson.springintegrationtest.model;


import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;


/**
 * Created by IntelliJ IDEA.
 * User: lbonacina
 * Date: 01/02/11
 * Time: 16.07
 */
@Entity
@Table(name = "USERS")
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class User implements Serializable {
// ------------------------------ FIELDS ------------------------------

    @Id
    @GenericGenerator(name = "generator", strategy = "increment")
    @GeneratedValue(generator = "generator")
    private Long id;

    @Version
    @Column(name = "HIBERNATE_OBJECT_VERSION")
    private long hibernateObjectVersion;

    @Column(name = "FIRST_NAME", nullable = false)
    private String firstName;

    @Column(name = "LAST_NAME", nullable = false)
    private String lastName;

    @Column(name = "EMAIL", nullable = true)
    private String email;

    @Column(name = "PHONE", nullable = true)
    private String phone;

    @Column(name = "USERNAME", nullable = true)
    private String username;

    @Column(name = "PASSWORD", nullable = true)
    private String password;

    @Column(name = "ENABLED", nullable = false)
    @Type(type = "true_false")
    private boolean enabled;


    public User() {
        this.id = null ;
        this.hibernateObjectVersion = 0 ;
        this.firstName = null;
        this.lastName = null;
        this.email = null;
        this.phone = null;
        this.username = null;
        this.password = null;
        this.enabled = false;
    }

    public User(String firstName, String lastName, String email, String phone, String username, String password) {
        this.id = null ;
        this.hibernateObjectVersion = 0 ;
        this.firstName = firstName;
        this.lastName = lastName;
        this.email = email;
        this.phone = phone;
        this.username = username;
        this.password = password;
        this.enabled = true ;
    }
    
    

    public Long getId() {

        return id;
    }

    public void setId(Long id) {

        this.id = id;
    }

    public long getHibernateObjectVersion() {

        return hibernateObjectVersion;
    }

    public void setHibernateObjectVersion(long hibernateObjectVersion) {

        this.hibernateObjectVersion = hibernateObjectVersion;
    }

    public String getFirstName() {

        return firstName;
    }

    public void setFirstName(String firstName) {

        this.firstName = firstName;
    }

    public String getLastName() {

        return lastName;
    }

    public void setLastName(String lastName) {

        this.lastName = lastName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    @Override
    public String toString() {
        return "User{" + "id=" + id + ", hibernateObjectVersion=" + hibernateObjectVersion + ", firstName=" + firstName + ", lastName=" + lastName + ", email=" + email + ", phone=" + phone + ", username=" + username + ", password=" + password + ", enabled=" + enabled + '}';
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 53 * hash + (this.firstName != null ? this.firstName.hashCode() : 0);
        hash = 53 * hash + (this.lastName != null ? this.lastName.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final User other = (User) obj;
        if ((this.firstName == null) ? (other.firstName != null) : !this.firstName.equals(other.firstName)) {
            return false;
        }
        if ((this.lastName == null) ? (other.lastName != null) : !this.lastName.equals(other.lastName)) {
            return false;
        }
        return true;
    }
    
}
